package com.ymatou.iapi.godfreightmgr.testcase;

import java.util.HashMap;
import java.util.Map;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.ymatou.iapi.godfreightmgr.parameter.CreateCollectionGoodsAddressBean;
import com.ymatou.iapi.godfreightmgr.parameter.GetCollectionGoodsAddressInfoBean;
import com.ymatou.iapi.godfreightmgr.service.GetCollectionGoodsAddressInfoCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.business.service.GodfreightmgrService;
import com.ymttest.business.service.shenqi.GodmchManageCallService;
import com.ymttest.database.model.godfreight.CollectiongoodsAddress;
/**
*自提点详情
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_GetCollectionGoodsAddressInfo{
	private static GetCollectionGoodsAddressInfoBean getcollectiongoodsaddressinfoBean;
	private static GetCollectionGoodsAddressInfoCall getcollectiongoodsaddressinfoCall;
	com.ymttest.database.sqlwapper.godfreight.CollectionGoodsWapper CollectionGoodsWapper;
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("自提点详情");
	}

	@Before
	public void caseUp() {
		getcollectiongoodsaddressinfoBean=new GetCollectionGoodsAddressInfoBean();
		getcollectiongoodsaddressinfoCall=new GetCollectionGoodsAddressInfoCall();
		CollectionGoodsWapper=new com.ymttest.database.sqlwapper.godfreight.CollectionGoodsWapper();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(getcollectiongoodsaddressinfoCall.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	private void verify(int addressid, CollectiongoodsAddress createcollectiongoodsaddressBean2) {
		CollectiongoodsAddress ca = CollectionGoodsWapper.selectCollectiongoodsAddress(addressid, createcollectiongoodsaddressBean2.getSellerId()).get(0);
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressName(), ca.getAddressName(), "验证AddressName");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressPic(), ca.getAddressPic(), "验证AddressPic");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAddressType(), ca.getAddressType(), "验证AddressType");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getAreaCode(), ca.getAreaCode(), "验证AreaCode");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getBaseAddress(), ca.getBaseAddress(), "验证BaseAddress");
		Logger.verifyNotNull( ca.getCreateTime(), "验证CreateTime");
//		Logger.verifyEquals(false, ca.getDeleted(), "验证Deleted");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getDetailAddress(), ca.getDetailAddress(), "验证DetailAddress");
		Logger.verifyEquals(createcollectiongoodsaddressBean2.getMobile(), ca.getMobile(), "验证Mobile");
		Logger.verifyNotNull( ca.getUpdateTime(), "验证CreateTime");
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCollectionGoodsAddressInfo_001() {
		Logger.start(true,"自提点详情查询成功");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
            //开启运营
            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
            //添加一个自提地址
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
            Map<Integer ,CreateCollectionGoodsAddressBean> m=new HashMap<Integer ,CreateCollectionGoodsAddressBean>();
            m.put(addressId, createcollectiongoodsaddressBean);
            getcollectiongoodsaddressinfoBean.setSellerId(mchId_channl);
            getcollectiongoodsaddressinfoBean.setAddressId(addressId);
			getcollectiongoodsaddressinfoCall.setData(getcollectiongoodsaddressinfoBean);
			getcollectiongoodsaddressinfoCall.callService();			
			Logger.verifyEquals("200",getcollectiongoodsaddressinfoCall.getString("code") , "验证返回");
			verify(addressId, getcollectiongoodsaddressinfoCall.getCollectiongoodsAddress());
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetCollectionGoodsAddressInfo_002() {
		Logger.start(true,"不输入addressid失败");
		try {
//			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
//            //开启运营
//            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
//            //添加一个自提地址
//            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
//            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
//            Map<Integer ,CreateCollectionGoodsAddressBean> m=new HashMap<Integer ,CreateCollectionGoodsAddressBean>();
//            m.put(addressId, createcollectiongoodsaddressBean);
//            getcollectiongoodsaddressinfoBean.setAddressId(addressId);
			getcollectiongoodsaddressinfoCall.setData(getcollectiongoodsaddressinfoBean);
			getcollectiongoodsaddressinfoCall.callService();			
			Logger.verifyEquals("400",getcollectiongoodsaddressinfoCall.getString("code") , "验证返回");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetCollectionGoodsAddressInfo_003() {
		Logger.start(true,"输入不存在addressid失败");
		try {
			getcollectiongoodsaddressinfoBean.setAddressId(-1);
			getcollectiongoodsaddressinfoCall.setData(getcollectiongoodsaddressinfoBean);
			getcollectiongoodsaddressinfoCall.callService();			
			Logger.verifyEquals("400",getcollectiongoodsaddressinfoCall.getString("code") , "验证返回");	
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P2.class})
	@TestCase
	public void Tc_GetCollectionGoodsAddressInfo_004() {
		Logger.start(true,"输入已删除addressid失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
            //开启运营
            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
            //添加一个自提地址
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean2 = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId2 = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean2);
            Map<Integer ,CreateCollectionGoodsAddressBean> m=new HashMap<Integer ,CreateCollectionGoodsAddressBean>();
            m.put(addressId, createcollectiongoodsaddressBean);
            GodfreightmgrService.deletecollectiongoodsaddressCall(addressId, mchId_channl);
            
            getcollectiongoodsaddressinfoBean.setSellerId(mchId_channl);
            getcollectiongoodsaddressinfoBean.setAddressId(addressId);
			getcollectiongoodsaddressinfoCall.setData(getcollectiongoodsaddressinfoBean);
			getcollectiongoodsaddressinfoCall.callService();			
			Logger.verifyEquals("400",getcollectiongoodsaddressinfoCall.getString("code") , "验证返回");
//			verify(addressId, getcollectiongoodsaddressinfoCall.getCollectiongoodsAddress()); 自提点不存在607
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_GetCollectionGoodsAddressInfo_005() {
		Logger.start(true,"不输入sellerid失败");
		try {
			Integer mchId_channl = GodmchManageCallService.CreateSellerMch();
            //开启运营
            GodfreightmgrService.setCollectionGoodsByAdminCall(mchId_channl, true);
            //添加一个自提地址
            CreateCollectionGoodsAddressBean createcollectiongoodsaddressBean = GodfreightmgrService.initCreateCollectionGoodsAddressBean(mchId_channl);
            int addressId = GodfreightmgrService.createcollectiongoodsaddressCall(createcollectiongoodsaddressBean);
            Map<Integer ,CreateCollectionGoodsAddressBean> m=new HashMap<Integer ,CreateCollectionGoodsAddressBean>();
            m.put(addressId, createcollectiongoodsaddressBean);
            getcollectiongoodsaddressinfoBean.setAddressId(addressId);
			getcollectiongoodsaddressinfoCall.setData(getcollectiongoodsaddressinfoBean);
			getcollectiongoodsaddressinfoCall.callService();			
			Logger.verifyEquals("400",getcollectiongoodsaddressinfoCall.getString("code") , "验证返回");
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}